const {
	Controller
} = require('uni-cloud-router');
const {
	success,
	exception,
	error,
	typeOf,
} = require("lg-utils");
module.exports = class LineController extends Controller {
	/***
		 @type GET 
		 @description : xxx
		 @param {type}
	***/
	async xxx() {
		try {
			const {
				service,
				data
			} = this.ctx;
			return await service.line.xxx();

		} catch (e) {
			return exception(this,"",e);
		}

	}
	/***
		 @type GET 
		 @description : 移除掉日期重复line数组项数据;
		 @param {type}
	***/
	async clearRepeatLineForDay() {
		try {
			const {
				service,
				data
			} = this.ctx;
			return await service.line.clearRepeatLineForDay(data);

		} catch (e) {
			return exception(this,"移除掉日期重复line数组项数据异常;",e);
		}

	}
	/***
		 @type GET 
		 @description : 根据股票symbol差值,更新Line集合;
		 @param {type}
	***/
	async refreshSymbolsWithStockByDiff() {
		try {
			const {
				service,
				data
			} = this.ctx;
			return await service.line.refreshSymbolsWithStockByDiff(data);
		} catch (e) {
			return exception(this,"根据股票symbol差值,更新Line集合异常;",e);
		}

	}
	
	/***
		 @type GET 
		 @description : 集合添加数据项
		 @param {type}
	***/
	async addIterForDay() {
		try {
			const {
				service,
				data
			} = this.ctx;
			return await service.line.addIterForDay(data);

		} catch (e) {
			return exception(this,"集合添加数据项异常;",e);
		}

	}
	/***
		 @type GET 
		 @description : 更新单个日K线数据
		 @param {
			 type = "",       k线类型
			 collection = {}, 目标集合
			 symbol = "",     股票的symbol
			 cycle = 0  	  更新周期
			 }
	***/
	async updateKline() {
		try {
			const {
				service,
				data
			} = this.ctx;
			return await service.line.updateKline(data);

		} catch (e) {
			return exception(e, this);
		}

	}


	/***
		 @type GET 
		 @description : 更新所有日K线数据
	     @param {}
	***/
	async updateDayKLineAll() {
		try {
			const {
				service,
				data = {}
			} = this.ctx;

			return await service.line.updateDayKLineAll();

		} catch (e) {
			return exception(this, "更新日K线数据异常;", e);
		}

	}

}
